package com.moefor.clover.util;

import java.security.MessageDigest;

public class Encrypt {
	public static String MD5(String data){
		StringBuffer dataStrBuf;
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");
			md.update(data.getBytes("UTF-8"));
			byte mdByte[] = md.digest();
			dataStrBuf = new StringBuffer();
			String str;
			for(byte b:mdByte){
				str = Integer.toHexString(b&0xff);
				if(str.length() == 1) dataStrBuf.append("0");
				dataStrBuf.append(str);
			}
			return dataStrBuf.toString().toLowerCase();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
